﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	  xmlns:local="clr-namespace:myBoard.Framework"
    xmlns:Custom="clr-namespace:myBoard.Framework"
    xmlns:Custom1="http://schemas.sheva.com/winfx/2006/xaml/presentation"
    x:Class="myBoard.Framework.Flipper"
    Width="249" Height="169" Background="{x:Null}">
	<UserControl.Resources>
    <Storyboard x:Key="FlipToBackSide">
      <BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.ViewIn3D)">
        <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>
        <DiscreteBooleanKeyFrame KeyTime="00:00:00.3000000" Value="False"/>
      </BooleanAnimationUsingKeyFrames>
      <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.EulerAngles)">
        <SplineThicknessKeyFrame KeyTime="00:00:00" Value="0,0,0,0"/>
        <SplineThicknessKeyFrame KeyTime="00:00:00.3000000" Value="90,0,0,0" KeySpline="0.5,0,1,1"/>
      </ThicknessAnimationUsingKeyFrames>
      <BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.ViewIn3D)">
        <DiscreteBooleanKeyFrame KeyTime="00:00:00.3000000" Value="True"/>
        <DiscreteBooleanKeyFrame KeyTime="00:00:00.6000000" Value="False"/>
      </BooleanAnimationUsingKeyFrames>
      <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.EulerAngles)">
        <SplineThicknessKeyFrame KeyTime="00:00:00.3000000" Value="-90,0,0,0"/>
        <SplineThicknessKeyFrame KeyTime="00:00:00.6000000" Value="0,0,0,0" KeySpline="0,0,0.5,1"/>
      </ThicknessAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideContentGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
        <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000" Value="{x:Static Visibility.Hidden}"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideContentGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
        <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000" Value="{x:Static Visibility.Visible}"/>
      </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="FlipToFrontSide">
      <BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.ViewIn3D)">
        <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
        <DiscreteBooleanKeyFrame KeyTime="00:00:00.1000000" Value="True"/>
      </BooleanAnimationUsingKeyFrames>
      <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.EulerAngles)">
        <SplineThicknessKeyFrame KeyTime="00:00:00" Value="0,0,0,0"/>
        <SplineThicknessKeyFrame KeyTime="00:00:00.3000000" Value="-90,0,0,0" KeySpline="0.5,0,1,1"/>
      </ThicknessAnimationUsingKeyFrames>
      <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.EulerAngles)">
        <SplineThicknessKeyFrame KeyTime="00:00:00" Value="90,0,0,0"/>
        <SplineThicknessKeyFrame KeyTime="00:00:00.3000000" Value="90,0,0,0"/>
        <SplineThicknessKeyFrame KeyTime="00:00:00.6000000" Value="0,0,0,0" KeySpline="0,0,0.5,1"/>
      </ThicknessAnimationUsingKeyFrames>
      <BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideRotatingControl" Storyboard.TargetProperty="(Custom:RotatingContentControl.ViewIn3D)">
        <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>        
      </BooleanAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_frontSideContentGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
        <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>        
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="_backSideContentGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
      	<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000" Value="{x:Static Visibility.Hidden}"/>
      </ObjectAnimationUsingKeyFrames>
    </Storyboard>
     	
	</UserControl.Resources>

    <Grid x:Name="_root">
      <local:RotatingContentControl Width="{Binding Path=ActualWidth, ElementName=_root, Mode=Default}" EulerAngles="0,0,0,0" ViewIn3D="False" RenderTransformOrigin="0.5,0.5" x:Name="_frontSideRotatingControl" Margin="0,0,0,0" Visibility="Visible" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="{Binding Path=ActualHeight, ElementName=_root, Mode=Default}">
        <local:RotatingContentControl.RenderTransform>
          <TransformGroup>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
            <SkewTransform AngleX="0" AngleY="0"/>
            <RotateTransform Angle="0"/>
            <TranslateTransform X="0" Y="0"/>
          </TransformGroup>
        </local:RotatingContentControl.RenderTransform>
        <Viewbox HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" RenderTransformOrigin="0.5,0.5" x:Name="_frontSideRotatingControlViewbox" Height="Auto">
          <Viewbox.RenderTransform>
            <TransformGroup>
              <ScaleTransform ScaleX="1" ScaleY="1"/>
              <SkewTransform AngleX="0" AngleY="0"/>
              <RotateTransform Angle="0"/>
              <TranslateTransform X="0" Y="0"/>
            </TransformGroup>
          </Viewbox.RenderTransform>

          <Grid x:Name="_frontSideContentGrid" Width="{Binding Path=ActualWidth, ElementName=_root, Mode=Default}" Height="{Binding Path=ActualHeight, ElementName=_root, Mode=Default}">

            <Button Content="This is front side button." x:Name="_frontSideViewboxContent" HorizontalAlignment="Center" VerticalAlignment="Center"/>
          </Grid>
        </Viewbox>
      </local:RotatingContentControl>
      <local:RotatingContentControl Width="{Binding Path=ActualWidth, ElementName=_root, Mode=Default}" EulerAngles="0,0,0,0" ViewIn3D="False" RenderTransformOrigin="0.5,0.5" x:Name="_backSideRotatingControl" Visibility="Visible" Height="{Binding Path=ActualHeight, ElementName=_root, Mode=Default}" IsEnabled="True">
        <local:RotatingContentControl.RenderTransform>
          <TransformGroup>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
            <SkewTransform AngleX="0" AngleY="0"/>
            <RotateTransform Angle="0"/>
            <TranslateTransform X="0" Y="0"/>
          </TransformGroup>
        </local:RotatingContentControl.RenderTransform>
        <Viewbox HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" RenderTransformOrigin="0.5,0.5" x:Name="_backSideRotatingControlViewbox" Height="Auto">
          <Viewbox.RenderTransform>
            <TransformGroup>
              <ScaleTransform ScaleX="1" ScaleY="1"/>
              <SkewTransform AngleX="0" AngleY="0"/>
              <RotateTransform Angle="0"/>
              <TranslateTransform X="0" Y="0"/>
            </TransformGroup>
          </Viewbox.RenderTransform>

          <Grid x:Name="_backSideContentGrid" Visibility="Collapsed"  Width="{Binding Path=ActualWidth, ElementName=_root, Mode=Default}" Height="{Binding Path=ActualHeight, ElementName=_root, Mode=Default}" IsEnabled="True">

            <Button Content="This is back side button." x:Name="_backSideViewboxContent" HorizontalAlignment="Center" IsEnabled="True" VerticalAlignment="Center"/>
          </Grid>
        </Viewbox>
      </local:RotatingContentControl>
	</Grid>
</UserControl>
